package spring.framework.beans.factory.support;

import spring.framework.beans.factory.config.SingletonBeanRegistry;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author pengzh
 * @class DefaultSingletonBeanRegistry
 * @since 2021-09-23
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {

    private Map<String, Object> singletonMap = new ConcurrentHashMap<>();

    @Override
    public Object getSingleton(String beanName) {
        return singletonMap.get(beanName);
    }

    public void addSingleton(String beanName, Object obj) {
        singletonMap.put(beanName, obj);
    }
}
